package com.web.base.open.service;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.base.open.dao.RoleDao;
import com.web.base.open.model.Role;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 开放平台角色业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2017年02月27日
 */
@Service("openRoleService")
@Transactional
@JdbcDataSource(Const.DS_BASE)
public class RoleService
{
	@Autowired
	private RoleDao roleDao;
	
	public RoleService()
	{
	}
	
	public Role save(Role role)
	{
		if (role.getId() == null)
		{
			roleDao.save(role);
		}
		else
		{
			roleDao.update(role);
		}
		Role a = roleDao.get(role.getId());
		return a;
	}
	
	public Role get(Integer id)
	{
		Role log = roleDao.get(id);
		return log;
	}
	
	public Page<Role> list(Role role, Page<Role> page)
	{
		page = roleDao.list(role, page);
		return page;
	}
	
	public List<Role> list(Role role)
	{
		List<Role> list = roleDao.list(role);
		return list;
	}
	
	public void delete(Role role)
	{
		roleDao.delete(role);
	}
	
}
